# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Guillermo Ramos <0xwille at gmail dot com>

pkgname=radare2
pkgver=5.8.4
pkgrel=1
pkgdesc='Open-source tools to disasm, debug, analyze and manipulate binary files'
url='https://radare.org'
arch=('loong64' 'x86_64')
license=('GPL3' 'LGPL3')
depends=('sh' 'capstone' 'libcapstone.so' 'openssl' 'libzip' 'zlib'
         'lz4' 'xxhash' 'libxxhash.so' 'file' 'libuv'
         'libzip.so' 'libmagic.so')
makedepends=('meson')
optdepends=('r2ghidra: ghidra decompiler plugin')
options=('!emptydirs')
source=(https://github.com/radare/radare2/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('3b7ef3756fa45dd1dc1e7293b278650734c4d8c160940215de7f1c46b8eb187829f92d6411ce5f60e5f0ea8c74ae8cc0abe4df44df0336f7f5cc7ff9ca177aca')
b2sums=('98bf3b694dcacbf27f87a42cd9a0c549a3780cb9e9cf3412f057286e38fea588f18c18277fc773dd38200329eea38c1bd958e0ce31f3577196befebeaa5911ed')

build() {
  cd ${pkgname}-${pkgver}
  touch libr/config.mk
  arch-meson build \
    -D use_sys_capstone=true \
    -D use_capstone_version=v4 \
    -D use_sys_magic=true \
    -D use_sys_zip=true \
    -D use_sys_zlib=true \
    -D use_sys_lz4=true \
    -D use_sys_xxhash=true \
    -D use_sys_openssl=true \
    -D use_libuv=true \
    -D use_webui=true \
    -D want_threads=false

  ninja -C build
}

package() {
  cd ${pkgname}-${pkgver}
  DESTDIR="${pkgdir}" ninja -C build install
  cp -r doc/* "${pkgdir}/usr/share/doc/radare2"
  ln -s /usr/share/man/man1/radare2.1.gz "${pkgdir}/usr/share/man/man1/r2.1.gz"
# Install missing header
  install -Dm644 shlr/sdb/include/sdb/rangstr.h -t "$pkgdir"/usr/include/libr/sdb
}

# vim: ts=2 sw=2 et:
